﻿/*
 * ===================================================
 * Author     : <ClueeZhuo>
 * Create Time: <2018/5/13 2:39:29>
 * Description: <This is a Description of This File.>
 * ===================================================
 */




using Microsoft.AspNetCore.Mvc;
using System;
using System.Threading.Tasks;

namespace helloworld.IOC
{
    public class MVCLib
    {
        public static Request ListenAndReceiveRequest(Uri address) => new Request();
        public static Controller ActivateController(Request request) => (Controller)new object();
        public static View ExecuteController(Controller controller) => new View();
        public static void RenderView(View view) => new object();

        public void Startup()
        {
            Uri uri = new Uri("http://localhost/mvcapp");
            while (true)
            {
                Request req = MVCLib.ListenAndReceiveRequest(uri);

                Task.Run(() => ProcessRequest(request: req));
            }
        }

        private void ProcessRequest(Request request)
        {
            Controller controller = MVCLib.ActivateController(request);

            View view = MVCLib.ExecuteController(controller);

            MVCLib.RenderView(view);
        }
    }

    public class Request
    {

    }

    public class View
    {

    }
}
